The UploadManager is a non-visual web server control that is required when using the Upload, OpenFileDialog and ProgressPanel controls. Only one instance of the UploadManager can be used on a single webform. This control manages page-level upload behavior settings such as file upload destination, temporary upload directory, and raising of file upload events.
Upload Destinations
By combining the settings of the UploadManager.SavePath and UploadManager.TempPath properties, file upload destinations can be configured in one of three ways.
- Streaming file data to a temporary file location
Setting the TempPath and SavePath properties will cause a temporary file to be written to the TempPath. When completed, the temporary file is moved to the SavePath location. This is an ideal configuration when reserving the SavePath for completed files as cancelled or truncated files will not be moved to the SavePath. - Streaming file data directly to a final file location
Setting only the SavePath property will cause files to be directly uploaded to the SavePath location. - Streaming file data to memory
Clearing both TempPath and SavePath values will cause files to be uploaded to server memory and is the ideal configuration for automated, direct streaming operations are required. For more information on using this configuration, see the Streaming File Data topic.
Limiting Files
The UploadManager is also used for setting page-level limitations on which type and size of files can be uploaded. To do so, use the following properties:
- UploadManager.Extensions - This property determines the list of allowable file extensions. By default, all file extensions are allowed.
- UploadManager.MaxFileSize - The maximum individual file size allowed (in kilobytes). Setting this property to 0 allows all file sizes permitted by the browser and/or server.
- UploadManager.MaxRequestSize - The maximum request size allowed (in kilobytes). This is the request size which includes the file data along with additional form field data. Setting this to 0 allows all request sizes up to the limit imposed by the browser and/or server.
Special Note regarding file size limitations: The maximum number of bytes that may be transferred is dependent on limits imposed by both the server and the browser. In general, the limit is 2 Gigabytes but there are exceptions. We have found the only browser capable of correctly forming a 'Content-Length' header for sizes between 2GB and 4GB was Internet Explorer 9.0. The only server that we could configure to allow files between 2GB and 4GB was the Visual Studio Development Server.
Events
Unlike other standard ASP.NET controls, the PowerWEB File Upload controls work together, are managed by the UploadManager control, and raise their individual events through the UploadManager. This simplifies the management of all upload operations on a given WebForm, as well as makes PostBack-free file uploading possible. The following events are exposed by the UploadManager control:
- UploadManager.FileUploadComplete - raised once for each file successfully uploaded
- UploadManager.FileUploadFailed - raised once for each file unsuccessfully uploaded
- UploadManager.UploadCancelled - raised once if a page-level upload operation is cancelled
- UploadManager.UploadComplete - raised once after all individual files have been uploaded
- UploadManager.UploadFailed - raised when an error affecting the entire Upload operation occurs.
- UploadManager.UploadProgress - raised once at each interval defined by the UploadManager.PollingInterval property (in ms). This event is also used for examining and working with uploaded file data as it is being streamed to the server.